const PENDING = 'PENDING'
const FULLFILLED = 'FULLFILLED'
const REJECTED = 'REJECTED'

class Promise {
    constructor(excute){
        this.state = PENDING
        this.value = ''
        this.error = ''

        const resolve  = (value) => {
            console.log(value)
            this.state = FULLFILLED
            this.value = value
        }

        const reject = (error) => {
            console.log(error)
            this.state = REJECTED
            this.error = error
        }

        try {
            excute(resolve, reject)
        } catch (e) {
            reject(e)
        }
    }

    then(onFullfilled){
        onFullfilled()
    }
}

new Promise((resolve, reject) => {
    resolve(123)
}).then(()=>{
    console.log(1111)
})